﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using WalkingTec.Mvvm.Core;
using System.Text.Json.Serialization;
using Digitalmes.Model;
using Digitalmes.Model.EquipmentManagement;

namespace Digitalmes.Model.EquipmentManagement
{
    /// <summary>
    /// 设备串田口
    /// </summary>
	[Table("EquipmentSerial")]

    [Display(Name = "_Model.EquipmentSerial")]
    public class EquipmentSerial : BasePoco,IPersistPoco,ITenant
    {
        [Key]
        [Display(Name = "_Model._EquipmentSerial._ID")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public new long ID { get; set; }
        [Display(Name = "_Model._EquipmentSerial._Equipment")]
        [Comment("关联设备")]
        public Equipment Equipment { get; set; }
        [Display(Name = "_Model._EquipmentSerial._Equipment")]
        [Comment("关联设备")]
        public long? EquipmentId { get; set; }
        [Display(Name = "_Model._EquipmentSerial._SerialName")]
        [StringLength(100, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Comment("串口")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public string SerialName { get; set; }
        [Display(Name = "_Model._EquipmentSerial._Description")]
        [Comment("说明")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public string Description { get; set; }
        [Display(Name = "_Model._EquipmentSerial._BaudRate")]
        [Comment("波特率")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public int? BaudRate { get; set; }
        [Display(Name = "_Model._EquipmentSerial._DataLength")]
        [Comment("数据长度")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public int? DataLength { get; set; }
        [Display(Name = "_Model._EquipmentSerial._StopBit")]
        [Comment("停止位")]
        [Precision(18,1)]
        [Range(0,2,ErrorMessage="Validate.{0}range{1}{2}")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public decimal? StopBit { get; set; }
        [Display(Name = "_Model._EquipmentSerial._Parity")]
        [Comment("奇偶校验")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public int? Parity { get; set; }
        [Display(Name = "_Model._EquipmentSerial._Threshold")]
        [Comment("最小长度")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public int? Threshold { get; set; }
        [Display(Name = "_Model._EquipmentSerial._Active")]
        [Comment("激活")]        
        public bool Active { get; set; } = false;

        [Display(Name = "_Model._EquipmentSerial._TagId")]
        [Comment("链接Tag")]
        public long? TagId { get; set; }
        [Display(Name = "_Model._EquipmentSerial._TagName")]
        [Comment("标记名称")]
        public string TagName { get; set; }
        [Display(Name = "_Model._EquipmentSerial._GlobalPushlish")]
        [Comment("全局发布")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public bool? GlobalPushlish { get; set; }
        [Display(Name = "_Model._EquipmentSerial._IsValid")]
        [Comment("是否有效")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public bool IsValid { get; set; } = true;
        [StringLength(50, ErrorMessage = "Validate.{0}stringmax{1}")]
        public string TenantCode { get; set; }

	}

}
